/**
 * 
 */
package it.sportingnola.soccernotes.listener;

import it.sportingnola.soccernotes.GoalEdit;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.Spinner;

/**
 * @author paolo
 */
public class TeamGoalItemListener implements OnItemSelectedListener {
    private final Spinner playerSpinner;
    GoalEdit goalEdit;

    public TeamGoalItemListener(GoalEdit ge) {
	goalEdit=ge;
	playerSpinner=ge.getPlayerSpinner();
    }

    /**
     * Abilita i campi player in e player out e riempie con i valori di binding
     * 
     * @see android.widget.AdapterView.OnItemSelectedListener#onItemSelected(android.widget.AdapterView,
     *      android.view.View, int, long)
     */
    @Override
    public void onItemSelected(AdapterView<?> parent, View v, int pos, long row) {
	playerSpinner.setEnabled(true);
	goalEdit.createAndSetPlayerAdapter(pos);
    }

    /**
     * Disabilita i campi player in e player out e cancella i valori di binding
     * 
     * @see android.widget.AdapterView.OnItemSelectedListener#onNothingSelected(android.widget.
     *      AdapterView )
     */
    @Override
    public void onNothingSelected(AdapterView<?> arg0) {
	playerSpinner.setEnabled(false);
    }

}
